package com.cysion.study.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.cysion.study.ktbox.base.BaseAdapter
import com.cysion.study.ktbox.base.BaseViewHolder
import com.cysion.study.R
import com.cysion.study.entity.ClassRecordEntity
import kotlinx.android.synthetic.main.item_class_record.view.*

class ClassRecordAdapter(mEntities: MutableList<ClassRecordEntity>, mContext: Context) :
    BaseAdapter<ClassRecordEntity>(mEntities, mContext) {

    companion object {

        //点击事件
        const val preview = 2000
        const val edit = 2001
        const val del = 2003
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder<ClassRecordEntity> {
        return ProMoneyHolder(
            LayoutInflater.from(mContext).inflate(R.layout.item_class_record, parent, false)
        )
    }

    class ProMoneyHolder(itemView: View) : BaseViewHolder<ClassRecordEntity>(itemView) {
        override fun fillData(obj: ClassRecordEntity, position: Int) {
            itemView?.apply {
                tv_time.text = "上课时间：" + obj.times
                if (obj.status == "2") {
                    tv_content.text = obj.reason
                } else {
                    tv_content.text = obj.remark
                }
                ////状态 0.授课确认中 1.授课对方已拒绝 2.已授课结束
                var status = obj.status
                if (status == "0") {
                    tv_status.text="授课确认中"
                    tv_status.setTextColor(resources.getColor(R.color.yellow_background))
                }else  if (status == "1") {
                    tv_status.text="授课对方已拒绝"
                    tv_status.setTextColor(resources.getColor(R.color.red_text))
                } else  if (status == "2") {
                    tv_status.text="已授课结束"
                    tv_status.setTextColor(resources.getColor(R.color.main_cl))
                }



            }
        }

    }
}